# -*- coding: utf-8 -*-
"""
Created on Sat Aug 15 17:25:29 2020

@author: Lenovo
"""


import pandas as pd
import numpy as np
import datetime,os
def EQP(): # 电量电价汇总竖直排列
    fieldnames=['日期','时间','中长期总量','日前量','实时电量','中长期价格','日前价格','实时价格']
    pwd = os.getcwd() #获取当前文件夹路径
    father_path=os.path.abspath(os.path.dirname(pwd)+os.path.sep+".") #获取父文件夹路径
    dict_d=pd.read_excel(father_path+"\8月现货数据.xlsx",sheet_name=None,header=[0,1],parse_dates=True)
    l=[]
    def isNaN(num): # 判断空值
        return num != num
    for i in dict_d.values():
        if isNaN(i.iloc[1,7]) == True:
            break # 跳出循环
        else:
            list_df=np.array(i[fieldnames]).tolist()
            l.extend(list_df)
    data=pd.DataFrame(l,columns=fieldnames)
    data['日期']=data['日期'].apply(str)
    def request_date(x):
        return x[0:10]
    data['日期']=data['日期'].apply(request_date)
    # r_time=datetime.datetime.now().strftime('%Y-%m-%d')
    # data.to_excel('现货数据竖直排列('+r_time+').xlsx',index=False,)
    data.to_excel('现货数据汇总竖直排列.xlsx',index=False,)
    print("现货数据汇总竖直排列表搞定了")